%% set const for V7_exp
xMin = -1;
xMax = 298;
x = xMin:xMax;    
tao1 = 16;
tao2 = 5;
A = 1;

%% set const for V7_filter
K = 10;
L = 5;
M = 16;

%% set fullscreen for graphics and text style
figure('Units', 'normalized', 'OuterPosition', [0 0 1 1]);
set(0,'DefaultAxesFontSize',14,'DefaultAxesFontName','Times New Roman');

%% calc, debug off
y = V7_exp(x, tao1, tao2, A);
y2 = V7_filter(y, K, L, M, false, x);
maxY = max(y);

%% drawing functions on different planes
%% draw V7_exp
subplot(1, 2, 1);
plot(x, y, 'b-', 'LineWidth', 2);
V7_graph_settings('Function Exp', true, 'Time', 'Signal', xMin, xMax, 0, maxY);

%% draw V7_filter
subplot(1, 2, 2);
plot(x, y2, 'b-', 'LineWidth', 2);
V7_graph_settings('Function Filter', true, 'Time', 'Signal', xMin, xMax, 0, maxY);
pause();

%% draw V7_exp, maxY = 16383
A = 16383/maxY;
subplot(1, 1, 1);
plot(x, y*A, 'b-', 'LineWidth', 2);
V7_graph_settings('Function Exp, maxY', true, 'Time', 'Signal', xMin, xMax, 0, 16383);

%% save to file V7_exp
fileId = fopen('V7_exp_data.txt', 'w');     
if (fileId == -1)                     
    error('File is not opened');
else
    n = numel(y);
    for i=1:n
        fprintf(fileId, '%d : output_data              <= 14''d %14.0f \n', i ,y(i)*A);   
    end
    fclose(fileId);  
end 

pause();
close();